]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Replace ClutterClickAction with new ClutterClickGesture
authorJonas Dreßler <verdre@v0yd.nl>
Tue, 8 Jul 2025 14:54:47 +0000 (16:54 +0200)
committerCarlos Garnacho <carlosg@gnome.org>
Thu, 28 Aug 2025 17:14:06 +0000 (19:14 +0200)
Nothing fancy either here, replace the old ClutterClickActions with the
new ClutterClickGesture.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2853>

js/ui/appDisplay.js
js/ui/backgroundMenu.js
js/ui/messageList.js
js/ui/popupMenu.js
js/ui/screenshot.js
js/ui/workspace.js
js/ui/workspaceThumbnail.js
src/st/st-entry.c

index 6aea0fdf744343b97d77e98f4c4b6cc1af017403..3fa758dcae4715c923f14660c3e0901430cc8422 100644 (file)
@@ -2495,16 +2495,14 @@ export const AppFolderDialog = GObject.registerClass({
 
         this.add_constraint(new Layout.MonitorConstraint({primary: true}));
 
-        const clickAction = new Clutter.ClickAction();
-        clickAction.connect('clicked', () => {
-            const [x, y] = clickAction.get_coords();
-            const actor =
-                global.stage.get_actor_at_pos(Clutter.PickMode.ALL, x, y);
-
-            if (!this._viewBox.contains(actor))
-                this.popdown();
-        });
-        this.add_action(clickAction);
+        const clickGesture = new Clutter.ClickGesture();
+        clickGesture.connect('may-recognize', () => {
+            const coords = clickGesture.get_coords_abs();
+            const [, x, y] = this.child.transform_stage_point(coords.x, coords.y);
+            return !this._viewBox.allocation.contains(x, y);
+        });
+        clickGesture.connect('recognize', () => this.popdown());
+        this.add_action(clickGesture);
 
         this._source = source;
         this._folder = folder;
index c88d1efc1dfcd970356d1f3db87f94ac6f5bf61e..26fd41eef361d173668aa41722329901c088e0c5 100644 (file)
@@ -44,21 +44,20 @@ export function addBackgroundMenu(actor, layoutManager) {
         if (actor._backgroundMenu.isOpen)
             return;
 
-        const coords = longPressGesture.get_coords();
-        const point = new Graphene.Point3D({x: coords.x, y: coords.y});
-        const transformedPoint = actor.apply_transform_to_point(point);
-        openMenu(transformedPoint.x, transformedPoint.y);
+        const {x, y} = longPressGesture.get_coords_abs();
+        openMenu(x, y);
     });
     actor.add_action(longPressGesture);
 
-    const clickAction = new Clutter.ClickAction();
-    clickAction.connect('clicked', action => {
-        if (action.get_button() === 3) {
-            let [x, y] = action.get_coords();
-            openMenu(x, y);
-        }
+    const clickGesture = new Clutter.ClickGesture({
+        required_button: Clutter.BUTTON_SECONDARY,
+        recognize_on_press: true,
     });
-    actor.add_action(clickAction);
+    clickGesture.connect('recognize', () => {
+        const {x, y} = clickGesture.get_coords_abs();
+        openMenu(x, y);
+    });
+    actor.add_action(clickGesture);
 
     actor.connect('destroy', () => {
         actor._backgroundMenu.destroy();
index 1d2453b0a01c2abbe44fe8f165fc78104dad2791..265d7a3f95b1bd2660da7ffb9505a3a698a95220 100644 (file)
@@ -856,7 +856,7 @@ export const NotificationMessageGroup = GObject.registerClass({
     },
 }, class NotificationMessageGroup extends St.Widget {
     constructor(source) {
-        const action =  new Clutter.ClickAction();
+        const action =  new Clutter.ClickGesture();
 
         // A widget that covers stacked messages so that they don't receive events
         const cover = new St.Widget({
@@ -912,7 +912,7 @@ export const NotificationMessageGroup = GObject.registerClass({
         });
 
         this._unexpandButton.connect('clicked', () => this.emit('expand-toggle-requested'));
-        action.connect('clicked', () => this.emit('expand-toggle-requested'));
+        action.connect('recognize', () => this.emit('expand-toggle-requested'));
 
         this._headerBox.add_child(this._unexpandButton);
         this.add_child(this._headerBox);
index a068ced5ef94a1402ccc07a4c6355158db5d6696..ced8a5ae82c10fa1d1cb277d28c7874e1db47d21 100644 (file)
@@ -103,18 +103,18 @@ export const PopupBaseMenuItem = GObject.registerClass({
         this._activatable = params.reactive && params.activate;
         this._sensitive = true;
 
-        this._clickAction = new Clutter.ClickAction({
+        this._clickGesture = new Clutter.ClickGesture({
             enabled: this._activatable,
         });
-        this._clickAction.connect('clicked',
+        this._clickGesture.connect('recognize',
             () => this.activate(Clutter.get_current_event()));
-        this._clickAction.connect('notify::pressed', () => {
-            if (this._clickAction.pressed)
+        this._clickGesture.connect('notify::pressed', () => {
+            if (this._clickGesture.pressed)
                 this.add_style_pseudo_class('active');
             else
                 this.remove_style_pseudo_class('active');
         });
-        this.add_action(this._clickAction);
+        this.add_action(this._clickGesture);
 
         if (!this._activatable)
             this.add_style_class_name('popup-inactive-menu-item');
index 6de759906a32bb4489542831b5ecb1e75a7cec7f..4513ff2878ddabbc37c75968049ba84c76df7b6f 100644 (file)
@@ -3036,13 +3036,15 @@ class PickPixel extends St.Widget {
         });
         this.add_constraint(constraint);
 
-        const action = new Clutter.ClickAction();
-        action.connect('clicked', async () => {
-            await this._pickColor(...action.get_coords());
+        const clickGesture = new Clutter.ClickGesture();
+        clickGesture.connect('recognize', async () => {
+            const {x, y} = clickGesture.get_coords_abs();
+
+            await this._pickColor(x, y);
             this._result = this._color;
             this._grabHelper.ungrab();
         });
-        this.add_action(action);
+        this.add_action(clickGesture);
 
         this._recolorEffect = new RecolorEffect({
             chroma: new Cogl.Color({
index 25c39aa5d6a03921eea40dde223d93b6ef683b40..05817b3a7af8d5df772ec81511e577f376d3f8c8 100644 (file)
@@ -1068,20 +1068,20 @@ class Workspace extends St.Widget {
         if (monitorIndex !== Main.layoutManager.primaryIndex)
             this.add_style_class_name('external-monitor');
 
-        const clickAction = new Clutter.ClickAction();
-        clickAction.connect('clicked', action => {
+        const clickGesture = new Clutter.ClickGesture({
+            required_button: Clutter.BUTTON_PRIMARY,
+        });
+        clickGesture.connect('recognize', () => {
             // Switch to the workspace when not the active one, leave the
             // overview otherwise.
-            if (action.get_button() === 1 || action.get_button() === 0) {
-                const leaveOverview = this._shouldLeaveOverview();
+            const leaveOverview = this._shouldLeaveOverview();
 
-                this.metaWorkspace?.activate(global.get_current_time());
-                if (leaveOverview)
-                    Main.overview.hide();
-            }
+            this.metaWorkspace?.activate(global.get_current_time());
+            if (leaveOverview)
+                Main.overview.hide();
         });
-        this.bind_property('mapped', clickAction, 'enabled', GObject.BindingFlags.SYNC_CREATE);
-        this._container.add_action(clickAction);
+        this.bind_property('mapped', clickGesture, 'enabled', GObject.BindingFlags.SYNC_CREATE);
+        this._container.add_action(clickGesture);
 
         this.connect('style-changed', this._onStyleChanged.bind(this));
         this.connect('destroy', this._onDestroy.bind(this));
index a34ebd44fb4fceba42363e7919ca0d13f0844138..34feaa1afe17ed830750523f9791759470565507 100644 (file)
@@ -93,10 +93,10 @@ export const WindowClone = GObject.registerClass({
             this);
         this.inDrag = false;
 
-        const clickAction = new Clutter.ClickAction();
-        clickAction.connect('clicked',
+        const clickGesture = new Clutter.ClickGesture();
+        clickGesture.connect('recognize',
             () => this.emit('selected', Clutter.get_current_event_time()));
-        this._draggable.addClickAction(clickAction);
+        this.add_action(clickGesture);
 
         let iter = win => {
             let actor = win.get_compositor_private();
@@ -631,13 +631,14 @@ export const ThumbnailsBox = GObject.registerClass({
 
         this._thumbnails = [];
 
-        const clickAction = new Clutter.ClickAction();
-        clickAction.connect('clicked', () => {
+        const clickGesture = new Clutter.ClickGesture();
+        clickGesture.connect('recognize', () => {
+            const coords = clickGesture.get_coords();
             this._activateThumbnailAtPoint(
-                ...clickAction.get_coords(),
+                coords.x, coords.y,
                 Clutter.get_current_event_time());
         });
-        this.add_action(clickAction);
+        this.add_action(clickGesture);
 
         Main.overview.connectObject(
             'showing', () => this._createThumbnails(),
@@ -719,9 +720,7 @@ export const ThumbnailsBox = GObject.registerClass({
         this.queue_relayout();
     }
 
-    _activateThumbnailAtPoint(stageX, stageY, time) {
-        const [r_, x] = this.transform_stage_point(stageX, stageY);
-
+    _activateThumbnailAtPoint(x, y, time) {
         const thumbnail = this._thumbnails.find(t => x >= t.x && x <= t.x + t.width);
         if (thumbnail)
             thumbnail.activate(time);
index fad92ae67112c0261c9621a6e9153869ccb78d45..e3a4b537f7a2c19bf7f6ce65899ca900c0fde51b 100644 (file)
@@ -1338,11 +1338,11 @@ st_entry_get_input_hints (StEntry *entry)
 }
 
 static void
-_st_entry_icon_clicked_cb (ClutterClickAction *action,
-                           ClutterActor       *actor,
-                           StEntry            *entry)
+icon_click_gesture_recognize_cb (ClutterClickGesture *gesture,
+                                 StEntry             *entry)
 {
   StEntryPrivate *priv = ST_ENTRY_PRIV (entry);
+  ClutterActor *actor = clutter_actor_meta_get_actor (CLUTTER_ACTOR_META (gesture));
 
   if (!clutter_actor_get_reactive (CLUTTER_ACTOR (entry)))
     return;
@@ -1367,17 +1367,17 @@ _st_entry_set_icon (StEntry       *entry,
 
   if (new_icon)
     {
-      ClutterAction *action;
+      ClutterAction *click_gesture;
 
       *icon = g_object_ref (new_icon);
 
       clutter_actor_set_reactive (*icon, TRUE);
       clutter_actor_add_child (CLUTTER_ACTOR (entry), *icon);
 
-      action = clutter_click_action_new ();
-      clutter_actor_add_action_with_name (*icon, "entry-icon-action", action);
-      g_signal_connect (action, "clicked",
-                        G_CALLBACK (_st_entry_icon_clicked_cb), entry);
+      click_gesture = clutter_click_gesture_new ();
+      clutter_actor_add_action_with_name (*icon, "entry-icon-click-gesture", click_gesture);
+      g_signal_connect (click_gesture, "recognize",
+                        G_CALLBACK (icon_click_gesture_recognize_cb), entry);
     }
 
   clutter_actor_queue_relayout (CLUTTER_ACTOR (entry));